/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import javax.swing.*;
import java.awt.event.*;

/**
 *
 * @author kayman
 */
public class AvanceGrafica extends JFrame{
 
    private JProgressBar barra;
    private static AvanceGrafica singleton;
    JFrame fr;
    
    private AvanceGrafica(JFrame fr){
    super("Graficando.....");
    JPanel pane= new JPanel();
    barra= new JProgressBar(0,100);
    barra.setValue(0);
    barra.setStringPainted(true);
    pane.add(barra);
    this.add(pane);
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    this.pack();
    this.setLocationRelativeTo(fr);
    //this.setVisible(true);
    //this.toFront();
    }
    
    public  static AvanceGrafica getFrame(JFrame fr){    
    if(singleton==null){
            singleton = new AvanceGrafica(fr);
            return singleton;      
    }else{
        return singleton; 
        }
    }
    
    public JProgressBar getBarra(){
        return barra;
    }
    
    public Object clone() throws CloneNotSupportedException {
        throw new CloneNotSupportedException(); 
}
    /*
   public static void main(String[] args){
       JFrame frm= new JFrame();
       AvanceGrafica avance=AvanceGrafica.getFrame(frm);
       frm.setVisible(true);
       frm.setSize(200,200);
       frm.setDefaultCloseOperation(3);
       int i=0;
       while(i<100){
           try{Thread.sleep(50);
           }catch(Exception e){}
           i+=1;
           avance.getBarra().setValue(i);
           avance.setVisible(true);
           avance.toFront();
       }
       avance.dispose();
       JOptionPane.showInputDialog("Hecho");
    }*/
}
